package com.clouddot.baipai.ui.adapter;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.clouddot.baipai.R;
import com.clouddot.baipai.http.entity.response.getClassInfoListResponse;

import java.util.List;

/**
 * Created by wxy on 2018/8/26.
 */

public class V_ClassInfoAdapter extends BaseQuickAdapter<getClassInfoListResponse.classInfoItem, BaseViewHolder> {

    private List<getClassInfoListResponse.classInfoItem> mData;

    public V_ClassInfoAdapter(List<getClassInfoListResponse.classInfoItem> mDataList) {
        super(R.layout.v_adapter_classinfo_item, mDataList);
        mData = mDataList;
    }


    @Override
    protected void convert(BaseViewHolder helper, final getClassInfoListResponse.classInfoItem item) {

        helper.setText(R.id.tv_date, item.CreateTimeText);
        helper.setText(R.id.tv_desc, item.Title);

        if (mData.get(0).Id == item.Id) {
            helper.setVisible(R.id.tv_dot_top, true);
        }

        helper.setOnClickListener(R.id.tv_desc, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onClicked(item.Id);
            }
        });
    }

    private AdapterItemClickListener listener;

    public void setOnClickListener(AdapterItemClickListener listener) {
        this.listener = listener;
    }

    public interface AdapterItemClickListener {

        void onClicked(String position);
    }

}
